//
//  ZineTableViewCell.m
//  YZZX
//
//  Created by Easaa on 15/5/11.
//  Copyright (c) 2015年 Easaa. All rights reserved.
//

#import "ZineTableViewCell.h"

#import "ZineViewmb.h"

@implementation ZineTableViewCell
{

    UIImageView  *imageviewss;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

//
-(id)initWithDataStyle:(UITableViewCellStyle)stylessss reuseIdentifier:(NSString *)nssstr
{
    self = [super initWithStyle:stylessss reuseIdentifier:nssstr];
    if(self)
    {
              
    }
    
    return self;
    
}


- (void)creatCellView:(HeadZlineMassgeModel *)Model
{
    
    self.mdoelData = Model;
    self.backgroundColor =RGBCOLOR(231, 231, 231);
    [self.contentView setUserInteractionEnabled:YES];
    
    imageviewss = [[UIImageView alloc]initWithFrame:CGRectMake(10, 5, Dev_ScreenWidth-20,60+Model.Articles.count*40+10)];
    [imageviewss  setImage:[[UIImage imageNamed:@"zhoukan_bg.png" ]stretchableImageWithLeftCapWidth:30 topCapHeight:30]];
    [imageviewss setUserInteractionEnabled:YES];

     [self.contentView addSubview:imageviewss];
   
    UILabel *TitleView = [[UILabel alloc] initWithFrame:CGRectMake(35, 0, Dev_ScreenWidth-40, 50)];
    TitleView.font = [UIFont boldSystemFontOfSize:20];  //UILabel的字体大小
    TitleView.numberOfLines = 0;  //必须定义这个属性，否则UILabel不会换行
    //labelTitle.textColor = RGBCOLOR(0, 0, 147);
    TitleView.textAlignment = NSTextAlignmentLeft;  //文本对齐方式
    //[labelTitle setBackgroundColor:[UIColor redColor]];
    TitleView.text =Model.CategoryName;
    [imageviewss addSubview:TitleView];
    
    UIView  *viewttTitle =[[UIView alloc]initWithFrame:CGRectMake(30, 55-0.5, TitleView.frame.size.width-20,0.5)];
    [self.contentView addSubview:viewttTitle];
    viewttTitle.backgroundColor =[UIColor redColor];
    

    for (int i = 0 ;i<Model.Articles.count ;i++)
    {
       ZlineMassgeModel  *modezlie =  Model.Articles[i];
        [self creatLable:modezlie.Title Tag:i :imageviewss];
    }


}

- (void)creatLable:(NSString *)title Tag:(NSInteger)tag :(UIView *)view
{
    UIButton *bottomButton = [UIButton buttonWithType:UIButtonTypeCustom];
    bottomButton.tag = tag ;
    bottomButton.frame = CGRectMake(20, 60+tag*40, Dev_ScreenWidth-50, 40);
    [bottomButton addTarget:self action:@selector(showViewZlineView:) forControlEvents:UIControlEventTouchUpInside];
    bottomButton.showsTouchWhenHighlighted = YES;
//    [bottomButton setBackgroundImage:[UIImage imageNamed:@"but_bg_n"] forState:UIControlStateNormal];
//    [bottomButton setBackgroundImage:[UIImage imageNamed:@"but_bg_h"] forState:UIControlStateHighlighted];
    [bottomButton setTitle:title forState:UIControlStateNormal];
    [bottomButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [bottomButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
    bottomButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    bottomButton.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
    //label.lineBreakMode = NSLineBreakByTruncatingMiddle;
    [view addSubview:bottomButton];
    
}

- (void)showViewZlineView:(UIButton *)but
{
    if(but.tag<self.mdoelData.Articles.count)
    {
//        ZilneListDataModel   *modelPush = [self.mdoelData.Articles objectAtIndex:but.tag];
//        ZineMassgeView  *zinemassgea =[[ZineMassgeView alloc]initWithEstablish:modelPush];
//        [self.TableviewNavDelegat.navigationController pushViewController:zinemassgea animated:YES];
        
        ZineViewmb  *zinetext= [[ZineViewmb alloc]init];
        zinetext.arrydataa = self.mdoelData.Articles;
        zinetext.Tag = but.tag;
        zinetext.headmdoelcount = self.headmdoelcount;
        zinetext.HeadmodelArry= self.HeadmodelArry;
        [self.TableviewNavDelegat.navigationController pushViewController:zinetext animated:YES];
    }

 }

@end
